%% @author Filippo Pacini <pacini@sgconsulting.it>
%% @copyright 2008 S.G. Consulting s.r.l.
%%
%% @doc ewgi module example. Uses sgte to render a web page.

-module(ewgi_sgte).

-export([render/1]).

-include_lib("ewgi/include/ewgi.hrl").

%% ewgi callback. This is the part that is called.
render(Ctx) ->
    % get template to render and data from ewgi.data environment 
    Tmpl = ewgi_api:get_data("sgte.tmpl", Ctx),
    Data = ewgi_api:get_data("sgte.data", Ctx),
    {ok, C} = sgte:compile(Tmpl),
    Body = sgte:render(C, Data),
    ewgi_api:set_response(#ewgi_response{status=?OK, headers=[], message_body=Body}, Ctx).
